﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Skyworth.CRM.Common;
using Skyworth.CRM.Service.IBLL;


namespace Skyworth.CRM.Web.SalesManagement
{
    public partial class EditReceivables :BasePage
    {
        ICustomerBLL custBLL = (ICustomerBLL)IocContainer.Instance.Resolve<ICustomerBLL>();
        IWeekLongBLL weekLongBLL = IocContainer.Instance.Resolve<IWeekLongBLL>();

        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {

            }

        }



        protected void btnSave_Click(object sender, EventArgs e)
        {
            try
            {
                Int32 custid = 0;
                DataTable dtcust = custBLL.Query(" and FName='" + this.txtCustomerName.Text.Trim() + "'");
                if (dtcust != null && dtcust.Rows.Count > 0)
                {
                    custid = Convert.ToInt32(dtcust.Rows[0]["Fitemid"].ToString());
                }
                weekLongBLL.InsertReceivables(Convert.ToInt32(this.ddlFcustType.SelectedValue.ToString()), custid, Convert.ToDateTime(this.txtFReceDate.Text), this.txtFnode.Text.Trim(), Convert.ToDecimal(this.txtFamount.Text), Convert.ToInt32(this.ddlFReceivablesType.SelectedValue.ToString()),this.txtFHuiNumber.Text.Trim(), Convert.ToInt32(this.ddlFisYes.SelectedValue.ToString()));

                    ClientScript.RegisterClientScriptBlock(this.GetType(), "closeThisPage", "<script language=\"JavaScript\">parent.addWindow.close();parent.location.href = parent.location.href;</script>");
            }
            catch (Exception exception)
            {
                Logger.Instance.Error(exception);
                Alert("发生异常：\r\n" + exception.Message);
            }

        }
    }
}
